//
//  TJUserAcountModel.swift
//  WeiBo
//
//  Created by TanJian on 15/12/7.
//  Copyright © 2015年 Joshpell. All rights reserved.
//

import UIKit

class TJUserAcountModel: NSObject,NSCoding {

    //token过期时间
    var expiresDate: NSDate?
    
    
    //用户昵称
    var screen_name: String?
    //用户头像
    var avatar_large: String?
    
    
//    var remind_in:Int = 0
    //类型设置为int后请求用户信息为空
    var uid:String?
    var access_token:String?
    var expires_in:NSTimeInterval = 0 {
        didSet{
            expiresDate = NSDate(timeIntervalSinceNow: expires_in)
        }
        
    }
    
    
    init(dict: [String: AnyObject]) {
        
        super.init()
        setValuesForKeysWithDictionary(dict)
        
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
    
    
    override var description:String {
    
        let dict = ["uid", "expiresDate","access_token","screen_name","avatar_large"]
        return dictionaryWithValuesForKeys(dict).description
        
    }
    
    
    //归档协议的方法

    required init?(coder aDecoder: NSCoder){
     
        uid = aDecoder.decodeObjectForKey("uid") as? String
        expiresDate = aDecoder.decodeObjectForKey("expiresDate") as? NSDate
        access_token = aDecoder.decodeObjectForKey("access_token") as? String
        avatar_large = aDecoder.decodeObjectForKey("avatar_large") as? String
        screen_name = aDecoder.decodeObjectForKey("screen_name") as? String
        
    }
    //解档
    func encodeWithCoder(aCoder: NSCoder){
        
        aCoder.encodeObject(uid, forKey: "uid")
        aCoder.encodeObject(expiresDate, forKey: "expiresDate")
        aCoder.encodeObject(access_token, forKey: "access_token")
        aCoder.encodeObject(avatar_large, forKey: "avatar_large")
        aCoder.encodeObject(screen_name, forKey: "screen_name")
        
    }
    
    


    
}






